package qgs.zisu.javaconcurrency.javaconcurrency.chapter3_createThread;

/**
 * @Author: 蔡翔
 * @Date: 2019/9/11 10:39
 * @Version 1.0
 */
public class CreateThread {
    public static void main(String[] args) {
        Thread thread = new Thread();
        Thread thread2 = new Thread(){
            @Override
            public void run(){
                System.out.println("==============");
            }
        };

        // 调用start 的时候，两个线程存在，一个线程是调用你这个start方法的线程，另外一个就是start启动的模板
        thread.start();
        thread2.start();
        System.out.println(thread.getName());
        System.out.println(thread2.getName());

        Thread thread3 = new Thread("myName");
        Thread thread4 = new Thread(()->{
            System.out.println("Runnable..");
        });

        System.out.println(thread3.getName());
        System.out.println(thread4.getName());

        // 第一个参数 是 回调函数
        Thread thread5 = new Thread(() ->{
            System.out.println("Runnnable..."+Thread.currentThread().getName());
        },"RunnableThread");
        thread5.start();
    }
}